﻿using System;
using System.Text;

namespace LeRenard.Core.Cryptography.Base64
{
    /// <summary>
    /// Base64 encryptor.
    /// </summary>
    public sealed class Base64Encryptor : CryptographyBase, IEncryptor
    {
        /// <summary>
        /// Creates a new <see cref="Base64Encryptor"/>.
        /// </summary>
        /// <param name="encoding">The encoding to be used.</param>
        public Base64Encryptor(Encoding encoding)
            : base(encoding)
        {
        }

        /// <summary>
		/// Encrypts the specified input.
		/// </summary>
		/// <param name="input">The input to be encrypted.</param>
		public string Encrypt(string input)
        {
            var inputBytes = this.Encoding.GetBytes(input);
            var inputAsBase64 = Convert.ToBase64String(inputBytes);

            return inputAsBase64;
        }

        /// <summary>
        /// Encrypts the specified input.
        /// </summary>
        /// <param name="input">The input to be encrypted.</param>        
        /// <returns>The input encrypted as a base64 string.</returns>
        public string Encrypt(byte[] input)
        {
            var inputAsBase64 = Convert.ToBase64String(input);

            return inputAsBase64;
        }
    }
}
